package umls.interfaces;

import java.sql.SQLException;
import java.util.LinkedList;
import java.util.List;

public class MySql extends data.MySql {

	public MySql(String h, String u, String p, String d) throws SQLException {
		super(h, u, p, d);
	}

	public List<String> getDescriptionFromAui(String aui)
			throws SQLException {
		return query("Select DEF from MRDEF where AUI='" + aui + "'", "DEF");

	}
	public List<String> getDescriptionFromCui(String cui)
	throws SQLException {
		return query("Select DEF from MRDEF where CUI='" + cui + "'", "DEF");
	
}
	public List<String> searchAUI(String term) throws SQLException{
		List<String> output = query("SELECT AUI FROM MRCONSO M where STR='"+term+"'", "AUI");
		return output; 
	}
	
	public List<String> searchCUI(String term) throws SQLException{
		List<String> output = query("SELECT DISTINCT CUI FROM MRCONSO M where STR='"+term+"'", "CUI");
		return output; 
	}
	public List<String> searchRelatedAUI(String AUI) throws SQLException{
		List<String> output = query("SELECT aui2 FROM MRREL M where aui1='"+AUI+"' and rel='RN'","aui2");
		return output;
	}
	public String getDefFromAUI(String aui)throws SQLException{

		LinkedList<String> output = query("SELECT * FROM MRCONSO where aui='"+aui+"'","STR");
		if (output.size()>0)
				return output.getLast();
		else return "";
	//	return output;
	}
}
